package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

/**
 * 反射机制访问方法上的注解
 */
public class ReflectDemo11 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //查看Person类sayHello方法上是否有注解
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getDeclaredMethod("sayHello");
        boolean mark = method.isAnnotationPresent(AutoRunMethod.class);
        System.out.println("是否被注解："+mark);
    }
}
